﻿#region DaBranchInfo
/*----------------------------------------------------------------
// 文件名：DaBranchInfo.cs
// 功能描述：类BranchInfo的数据访问层
//
// 
// 创建时间：2009-07-11 DtataAccess template . Ver 5.0.20090413
//
// 修改标识： 
// 修改描述： 
//----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Globalization;
using System.Text;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

using Las.Model; 


namespace Las.Dal
{
	///可以继承更上层接口,IBranchInfo ,数据访问层基类DaBase，
	///DaBase中包含了DbException异常处理静态方法
    public	partial  class DaBranchInfo:DaBase<MoBranchInfo>
    {	 
		#region SQL const
		internal const string TABLE_COLUMNS=" BRANCH_ID ,PARENT_BRANCH_ID ,ARM_TYPE ,SPECIALTY_PHASE ,BRANCH_NAME ,BRANCH_SHORT_NAME ,ISDEPT ,ISDEL ,CANLOG ,MIN_BRANCH_ID ,RANK ,TRAINALL ,BZS ,GBBZS ,ZSBZS ,LNNDCJ ,LNDJPD ,LNHDRY ,LNJCJS ,LNCJDXHD   ";
		
		internal const string SQL_INSERT="INSERT INTO MT_BRANCH_INFO ("+TABLE_COLUMNS+") VALUES (@BranchId,@ParentBranchId,@ArmType,@SpecialtyPhase,@BranchName,@BranchShortName,@Isdept,@Isdel,@Canlog,@MinBranchId,@Rank,@Trainall,@Bzs,@Gbbzs,@Zsbzs,@Lnndcj,@Lndjpd,@Lnhdry,@Lnjcjs,@Lncjdxhd)";
		internal const string SQL_SELECT="SELECT "+TABLE_COLUMNS+" FROM MT_BRANCH_INFO  ";
		internal const string SQL_SELECT_ONE=SQL_SELECT+" WHERE BRANCH_ID=@BranchId";                              
		
		internal const string SQL_EXIST="SELECT COUNT(*) FROM MT_BRANCH_INFO  WHERE BRANCH_ID=@BranchId  ";
		internal const string SQL_UPDATE="UPDATE MT_BRANCH_INFO SET PARENT_BRANCH_ID=@ParentBranchId, ARM_TYPE=@ArmType, SPECIALTY_PHASE=@SpecialtyPhase, BRANCH_NAME=@BranchName, BRANCH_SHORT_NAME=@BranchShortName, ISDEPT=@Isdept, ISDEL=@Isdel, CANLOG=@Canlog, MIN_BRANCH_ID=@MinBranchId, RANK=@Rank, TRAINALL=@Trainall, BZS=@Bzs, GBBZS=@Gbbzs, ZSBZS=@Zsbzs, LNNDCJ=@Lnndcj, LNDJPD=@Lndjpd, LNHDRY=@Lnhdry, LNJCJS=@Lnjcjs, LNCJDXHD=@Lncjdxhd WHERE BRANCH_ID=@BranchId";
		
		internal const string SQL_DELETE_DEFAULT = "DELETE FROM MT_BRANCH_INFO ";
		internal const string SQL_DELETE="DELETE FROM MT_BRANCH_INFO WHERE BRANCH_ID=@BranchId";
		
		internal const string SQL_COUNT="SELECT COUNT(*) FROM mt_branch_info ";
		#endregion
		       
		#region Constructor
	 
		/// <summary>
        /// 默认构造函数，使用配置文件中默认的数据库配置。
        /// </summary>
		public DaBranchInfo ()
		{ 
			this.db=DatabaseFactory.CreateDatabase();
		}
		/// <summary>
        /// 使用指定的databaseName数据库配置。
        /// </summary>
        /// <param name="databaseName">配置文件中数据库的配置名称。</param>
		public DaBranchInfo (string databaseName)
		{ 
            this.db = DatabaseFactory.CreateDatabase(databaseName);
		} 
		
		public DaBranchInfo (Database db)
		{ 
            this.db = db;
		} 
		
		#endregion
		
		//以下是CRUD方法，每个方法都有引入外部事务的版本

		#region 构造器模块
		
        protected override MoBranchInfo ConstructT()
        {
            return new MoBranchInfo();
        }
        #endregion
		
	    
		
		#region Add模块 Helper
		
		///build the command object.It never throw exception.
		protected override  DbCommand ConstructAddCommand(Database db)
		{
			DbCommand dbCommand = db.GetSqlStringCommand(SQL_INSERT);
			 
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString);
			db.AddInParameter(dbCommand,"ParentBranchId",DbType.AnsiString);
			db.AddInParameter(dbCommand,"ArmType",DbType.AnsiString);
			db.AddInParameter(dbCommand,"SpecialtyPhase",DbType.AnsiString);
			db.AddInParameter(dbCommand,"BranchName",DbType.String);
			db.AddInParameter(dbCommand,"BranchShortName",DbType.String);
			db.AddInParameter(dbCommand,"Isdept",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Isdel",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Canlog",DbType.AnsiString);
			db.AddInParameter(dbCommand,"MinBranchId",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Rank",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Trainall",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Bzs",DbType.Int32);
			db.AddInParameter(dbCommand,"Gbbzs",DbType.Int32);
			db.AddInParameter(dbCommand,"Zsbzs",DbType.Int32);
			db.AddInParameter(dbCommand,"Lnndcj",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lndjpd",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lnhdry",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lnjcjs",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lncjdxhd",DbType.AnsiString);
			return dbCommand;
		}		
		protected override DbCommand ConstructAddCommand(Database db,MoBranchInfo entity)
		{
			DbCommand dbCommand=db.GetSqlStringCommand(SQL_INSERT);			 
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString,entity.BranchId);
			db.AddInParameter(dbCommand,"ParentBranchId",DbType.AnsiString,entity.ParentBranchId);
			db.AddInParameter(dbCommand,"ArmType",DbType.AnsiString,entity.ArmType);
			db.AddInParameter(dbCommand,"SpecialtyPhase",DbType.AnsiString,entity.SpecialtyPhase);
			db.AddInParameter(dbCommand,"BranchName",DbType.String,entity.BranchName);
			db.AddInParameter(dbCommand,"BranchShortName",DbType.String,entity.BranchShortName);
			db.AddInParameter(dbCommand,"Isdept",DbType.AnsiString,entity.Isdept);
			db.AddInParameter(dbCommand,"Isdel",DbType.AnsiString,entity.Isdel);
			db.AddInParameter(dbCommand,"Canlog",DbType.AnsiString,entity.Canlog);
			db.AddInParameter(dbCommand,"MinBranchId",DbType.AnsiString,entity.MinBranchId);
			db.AddInParameter(dbCommand,"Rank",DbType.AnsiString,entity.Rank);
			db.AddInParameter(dbCommand,"Trainall",DbType.AnsiString,entity.Trainall);
			db.AddInParameter(dbCommand,"Bzs",DbType.Int32,entity.Bzs);
			db.AddInParameter(dbCommand,"Gbbzs",DbType.Int32,entity.Gbbzs);
			db.AddInParameter(dbCommand,"Zsbzs",DbType.Int32,entity.Zsbzs);
			db.AddInParameter(dbCommand,"Lnndcj",DbType.AnsiString,entity.Lnndcj);
			db.AddInParameter(dbCommand,"Lndjpd",DbType.AnsiString,entity.Lndjpd);
			db.AddInParameter(dbCommand,"Lnhdry",DbType.AnsiString,entity.Lnhdry);
			db.AddInParameter(dbCommand,"Lnjcjs",DbType.AnsiString,entity.Lnjcjs);
			db.AddInParameter(dbCommand,"Lncjdxhd",DbType.AnsiString,entity.Lncjdxhd);
			return dbCommand;
		}
		
		protected override DbCommand PopulateAddCommandParameters(Database db,DbCommand addCmd,MoBranchInfo entity)
		{
			db.SetParameterValue(addCmd,"BranchId",entity.BranchId);
			db.SetParameterValue(addCmd,"ParentBranchId",entity.ParentBranchId);
			db.SetParameterValue(addCmd,"ArmType",entity.ArmType);
			db.SetParameterValue(addCmd,"SpecialtyPhase",entity.SpecialtyPhase);
			db.SetParameterValue(addCmd,"BranchName",entity.BranchName);
			db.SetParameterValue(addCmd,"BranchShortName",entity.BranchShortName);
			db.SetParameterValue(addCmd,"Isdept",entity.Isdept);
			db.SetParameterValue(addCmd,"Isdel",entity.Isdel);
			db.SetParameterValue(addCmd,"Canlog",entity.Canlog);
			db.SetParameterValue(addCmd,"MinBranchId",entity.MinBranchId);
			db.SetParameterValue(addCmd,"Rank",entity.Rank);
			db.SetParameterValue(addCmd,"Trainall",entity.Trainall);
			db.SetParameterValue(addCmd,"Bzs",entity.Bzs);
			db.SetParameterValue(addCmd,"Gbbzs",entity.Gbbzs);
			db.SetParameterValue(addCmd,"Zsbzs",entity.Zsbzs);
			db.SetParameterValue(addCmd,"Lnndcj",entity.Lnndcj);
			db.SetParameterValue(addCmd,"Lndjpd",entity.Lndjpd);
			db.SetParameterValue(addCmd,"Lnhdry",entity.Lnhdry);
			db.SetParameterValue(addCmd,"Lnjcjs",entity.Lnjcjs);
			db.SetParameterValue(addCmd,"Lncjdxhd",entity.Lncjdxhd);
			return addCmd;
		}
		
		protected override DbCommand PopulateAddCommandParameters(Database db,DbCommand addCmd,DataRow row)
		{
			db.SetParameterValue(addCmd,"BranchId",row["BranchId"]);
			db.SetParameterValue(addCmd,"ParentBranchId",row["ParentBranchId"]);
			db.SetParameterValue(addCmd,"ArmType",row["ArmType"]);
			db.SetParameterValue(addCmd,"SpecialtyPhase",row["SpecialtyPhase"]);
			db.SetParameterValue(addCmd,"BranchName",row["BranchName"]);
			db.SetParameterValue(addCmd,"BranchShortName",row["BranchShortName"]);
			db.SetParameterValue(addCmd,"Isdept",row["Isdept"]);
			db.SetParameterValue(addCmd,"Isdel",row["Isdel"]);
			db.SetParameterValue(addCmd,"Canlog",row["Canlog"]);
			db.SetParameterValue(addCmd,"MinBranchId",row["MinBranchId"]);
			db.SetParameterValue(addCmd,"Rank",row["Rank"]);
			db.SetParameterValue(addCmd,"Trainall",row["Trainall"]);
			db.SetParameterValue(addCmd,"Bzs",row["Bzs"]);
			db.SetParameterValue(addCmd,"Gbbzs",row["Gbbzs"]);
			db.SetParameterValue(addCmd,"Zsbzs",row["Zsbzs"]);
			db.SetParameterValue(addCmd,"Lnndcj",row["Lnndcj"]);
			db.SetParameterValue(addCmd,"Lndjpd",row["Lndjpd"]);
			db.SetParameterValue(addCmd,"Lnhdry",row["Lnhdry"]);
			db.SetParameterValue(addCmd,"Lnjcjs",row["Lnjcjs"]);
			db.SetParameterValue(addCmd,"Lncjdxhd",row["Lncjdxhd"]);
			return addCmd;
		}
		
		#endregion
		    
		#region Update模块 Helper
		
		protected override DbCommand ConstructUpdateCommand(Database db)
		{
			DbCommand dbCommand=db.GetSqlStringCommand(SQL_UPDATE);		    
			db.AddInParameter(dbCommand,"ParentBranchId",DbType.AnsiString);
			db.AddInParameter(dbCommand,"ArmType",DbType.AnsiString);
			db.AddInParameter(dbCommand,"SpecialtyPhase",DbType.AnsiString);
			db.AddInParameter(dbCommand,"BranchName",DbType.String);
			db.AddInParameter(dbCommand,"BranchShortName",DbType.String);
			db.AddInParameter(dbCommand,"Isdept",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Isdel",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Canlog",DbType.AnsiString);
			db.AddInParameter(dbCommand,"MinBranchId",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Rank",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Trainall",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Bzs",DbType.Int32);
			db.AddInParameter(dbCommand,"Gbbzs",DbType.Int32);
			db.AddInParameter(dbCommand,"Zsbzs",DbType.Int32);
			db.AddInParameter(dbCommand,"Lnndcj",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lndjpd",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lnhdry",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lnjcjs",DbType.AnsiString);
			db.AddInParameter(dbCommand,"Lncjdxhd",DbType.AnsiString);
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString);
			 
			return dbCommand;
		}
		protected override DbCommand ConstructUpdateCommand(Database db,MoBranchInfo entity)
		{
			DbCommand dbCommand=db.GetSqlStringCommand(SQL_UPDATE);		    
			db.AddInParameter(dbCommand,"ParentBranchId",DbType.AnsiString,entity.ParentBranchId);
			db.AddInParameter(dbCommand,"ArmType",DbType.AnsiString,entity.ArmType);
			db.AddInParameter(dbCommand,"SpecialtyPhase",DbType.AnsiString,entity.SpecialtyPhase);
			db.AddInParameter(dbCommand,"BranchName",DbType.String,entity.BranchName);
			db.AddInParameter(dbCommand,"BranchShortName",DbType.String,entity.BranchShortName);
			db.AddInParameter(dbCommand,"Isdept",DbType.AnsiString,entity.Isdept);
			db.AddInParameter(dbCommand,"Isdel",DbType.AnsiString,entity.Isdel);
			db.AddInParameter(dbCommand,"Canlog",DbType.AnsiString,entity.Canlog);
			db.AddInParameter(dbCommand,"MinBranchId",DbType.AnsiString,entity.MinBranchId);
			db.AddInParameter(dbCommand,"Rank",DbType.AnsiString,entity.Rank);
			db.AddInParameter(dbCommand,"Trainall",DbType.AnsiString,entity.Trainall);
			db.AddInParameter(dbCommand,"Bzs",DbType.Int32,entity.Bzs);
			db.AddInParameter(dbCommand,"Gbbzs",DbType.Int32,entity.Gbbzs);
			db.AddInParameter(dbCommand,"Zsbzs",DbType.Int32,entity.Zsbzs);
			db.AddInParameter(dbCommand,"Lnndcj",DbType.AnsiString,entity.Lnndcj);
			db.AddInParameter(dbCommand,"Lndjpd",DbType.AnsiString,entity.Lndjpd);
			db.AddInParameter(dbCommand,"Lnhdry",DbType.AnsiString,entity.Lnhdry);
			db.AddInParameter(dbCommand,"Lnjcjs",DbType.AnsiString,entity.Lnjcjs);
			db.AddInParameter(dbCommand,"Lncjdxhd",DbType.AnsiString,entity.Lncjdxhd);
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString,entity.BranchId);
			 
			return dbCommand;
		}
		
		protected override DbCommand PopulateUpdateCommandParameters(Database db,DbCommand updateCmd,MoBranchInfo entity)
		{
			db.SetParameterValue(updateCmd,"ParentBranchId",entity.ParentBranchId);
			db.SetParameterValue(updateCmd,"ArmType",entity.ArmType);
			db.SetParameterValue(updateCmd,"SpecialtyPhase",entity.SpecialtyPhase);
			db.SetParameterValue(updateCmd,"BranchName",entity.BranchName);
			db.SetParameterValue(updateCmd,"BranchShortName",entity.BranchShortName);
			db.SetParameterValue(updateCmd,"Isdept",entity.Isdept);
			db.SetParameterValue(updateCmd,"Isdel",entity.Isdel);
			db.SetParameterValue(updateCmd,"Canlog",entity.Canlog);
			db.SetParameterValue(updateCmd,"MinBranchId",entity.MinBranchId);
			db.SetParameterValue(updateCmd,"Rank",entity.Rank);
			db.SetParameterValue(updateCmd,"Trainall",entity.Trainall);
			db.SetParameterValue(updateCmd,"Bzs",entity.Bzs);
			db.SetParameterValue(updateCmd,"Gbbzs",entity.Gbbzs);
			db.SetParameterValue(updateCmd,"Zsbzs",entity.Zsbzs);
			db.SetParameterValue(updateCmd,"Lnndcj",entity.Lnndcj);
			db.SetParameterValue(updateCmd,"Lndjpd",entity.Lndjpd);
			db.SetParameterValue(updateCmd,"Lnhdry",entity.Lnhdry);
			db.SetParameterValue(updateCmd,"Lnjcjs",entity.Lnjcjs);
			db.SetParameterValue(updateCmd,"Lncjdxhd",entity.Lncjdxhd);
			db.SetParameterValue(updateCmd,"BranchId",entity.BranchId);
			return updateCmd;
		}
		protected override DbCommand PopulateUpdateCommandParameters(Database db,DbCommand updateCmd,DataRow row)
		{
			db.SetParameterValue(updateCmd,"ParentBranchId",row["ParentBranchId"]);
			db.SetParameterValue(updateCmd,"ArmType",row["ArmType"]);
			db.SetParameterValue(updateCmd,"SpecialtyPhase",row["SpecialtyPhase"]);
			db.SetParameterValue(updateCmd,"BranchName",row["BranchName"]);
			db.SetParameterValue(updateCmd,"BranchShortName",row["BranchShortName"]);
			db.SetParameterValue(updateCmd,"Isdept",row["Isdept"]);
			db.SetParameterValue(updateCmd,"Isdel",row["Isdel"]);
			db.SetParameterValue(updateCmd,"Canlog",row["Canlog"]);
			db.SetParameterValue(updateCmd,"MinBranchId",row["MinBranchId"]);
			db.SetParameterValue(updateCmd,"Rank",row["Rank"]);
			db.SetParameterValue(updateCmd,"Trainall",row["Trainall"]);
			db.SetParameterValue(updateCmd,"Bzs",row["Bzs"]);
			db.SetParameterValue(updateCmd,"Gbbzs",row["Gbbzs"]);
			db.SetParameterValue(updateCmd,"Zsbzs",row["Zsbzs"]);
			db.SetParameterValue(updateCmd,"Lnndcj",row["Lnndcj"]);
			db.SetParameterValue(updateCmd,"Lndjpd",row["Lndjpd"]);
			db.SetParameterValue(updateCmd,"Lnhdry",row["Lnhdry"]);
			db.SetParameterValue(updateCmd,"Lnjcjs",row["Lnjcjs"]);
			db.SetParameterValue(updateCmd,"Lncjdxhd",row["Lncjdxhd"]);
			db.SetParameterValue(updateCmd,"BranchId",row["BranchId"]);
			return updateCmd;
		}
		
		protected override void PrepareDataAdapterCommand(Database db,out DbCommand dbInsertCommand,
		                     out DbCommand dbUpdateCommand,out DbCommand dbDeleteCommand)
		{
			dbInsertCommand = db.GetSqlStringCommand(SQL_INSERT);
			#region set insert cmd parameters
			db.AddInParameter(dbInsertCommand, "BranchId",DbType.AnsiString, "BRANCH_ID", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "ParentBranchId",DbType.AnsiString, "PARENT_BRANCH_ID", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "ArmType",DbType.AnsiString, "ARM_TYPE", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "SpecialtyPhase",DbType.AnsiString, "SPECIALTY_PHASE", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "BranchName",DbType.String, "BRANCH_NAME", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "BranchShortName",DbType.String, "BRANCH_SHORT_NAME", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Isdept",DbType.AnsiString, "ISDEPT", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Isdel",DbType.AnsiString, "ISDEL", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Canlog",DbType.AnsiString, "CANLOG", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "MinBranchId",DbType.AnsiString, "MIN_BRANCH_ID", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Rank",DbType.AnsiString, "RANK", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Trainall",DbType.AnsiString, "TRAINALL", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Bzs",DbType.Int32, "BZS", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Gbbzs",DbType.Int32, "GBBZS", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Zsbzs",DbType.Int32, "ZSBZS", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Lnndcj",DbType.AnsiString, "LNNDCJ", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Lndjpd",DbType.AnsiString, "LNDJPD", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Lnhdry",DbType.AnsiString, "LNHDRY", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Lnjcjs",DbType.AnsiString, "LNJCJS", DataRowVersion.Current);
			db.AddInParameter(dbInsertCommand, "Lncjdxhd",DbType.AnsiString, "LNCJDXHD", DataRowVersion.Current);
			#endregion
			dbUpdateCommand = db.GetSqlStringCommand(SQL_UPDATE);
			#region Set update cmd value parameters
			db.AddInParameter(dbUpdateCommand, "ParentBranchId", DbType.AnsiString, "PARENT_BRANCH_ID", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "ArmType", DbType.AnsiString, "ARM_TYPE", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "SpecialtyPhase", DbType.AnsiString, "SPECIALTY_PHASE", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "BranchName", DbType.String, "BRANCH_NAME", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "BranchShortName", DbType.String, "BRANCH_SHORT_NAME", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Isdept", DbType.AnsiString, "ISDEPT", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Isdel", DbType.AnsiString, "ISDEL", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Canlog", DbType.AnsiString, "CANLOG", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "MinBranchId", DbType.AnsiString, "MIN_BRANCH_ID", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Rank", DbType.AnsiString, "RANK", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Trainall", DbType.AnsiString, "TRAINALL", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Bzs", DbType.Int32, "BZS", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Gbbzs", DbType.Int32, "GBBZS", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Zsbzs", DbType.Int32, "ZSBZS", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Lnndcj", DbType.AnsiString, "LNNDCJ", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Lndjpd", DbType.AnsiString, "LNDJPD", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Lnhdry", DbType.AnsiString, "LNHDRY", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Lnjcjs", DbType.AnsiString, "LNJCJS", DataRowVersion.Current);
			db.AddInParameter(dbUpdateCommand, "Lncjdxhd", DbType.AnsiString, "LNCJDXHD", DataRowVersion.Current);
			#endregion
			#region set update cmd pk where parameters
			db.AddInParameter(dbUpdateCommand, "BranchId", DbType.AnsiString, "BRANCH_ID", DataRowVersion.Current);
			#endregion			
			dbDeleteCommand = db.GetSqlStringCommand(SQL_DELETE);
			#region set delete cmd pk where parameters
			db.AddInParameter(dbDeleteCommand, "BranchId", DbType.AnsiString, "BRANCH_ID", DataRowVersion.Current);
			#endregion
		}
		#endregion	
		
		#region Delete模块 Helper		
		
		protected override DbCommand ConstructDeleteCommand(Database db)
		{
			DbCommand dbCommand=db.GetSqlStringCommand(SQL_DELETE);
			 
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString);
			 
			return dbCommand;
		}		
		protected override DbCommand ConstructDeleteCommand(Database db,MoBranchInfo entity)
		{
			DbCommand dbCommand=db.GetSqlStringCommand(SQL_DELETE);
			 
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString,entity.BranchId);
		 
			return dbCommand;
		}
		
		protected override DbCommand ConstructDeleteCommandForWhere(Database db, string where)
        {
            return db.GetSqlStringCommand(SQL_DELETE_DEFAULT + where);            
        }

        protected override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, MoBranchInfo entity)
        {
			db.SetParameterValue(deleteCmd,"BranchId",entity.BranchId);
			return deleteCmd;
        }

        protected override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, DataRow row)
        {
			db.SetParameterValue(deleteCmd,"BranchId",row["BranchId"]);
			return deleteCmd;
        }      
		
		#endregion helper
		
		#region Query模块 Helper

        protected override DbCommand ConstructQueryCommand(string condition)
        {
            return db.GetSqlStringCommand(SQL_SELECT + condition);
        }

        #endregion
		
		#region GetEntity(s)模块 Helper
        
		protected override DbCommand ConstructSelectOneCommand(Database db,MoBranchInfo entity)
		{
			DbCommand dbCommand=db.GetSqlStringCommand(SQL_SELECT_ONE);
			 
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString,entity.BranchId);
			return dbCommand;
		}
		
		protected override void PopulateEntityByDataReader(IDataReader reader,ref MoBranchInfo entity)
		{
			if (!reader.IsDBNull(0)) entity.BranchId = reader.GetString(0);
			if (!reader.IsDBNull(1)) entity.ParentBranchId = reader.GetString(1);
			if (!reader.IsDBNull(2)) entity.ArmType = reader.GetString(2);
			if (!reader.IsDBNull(3)) entity.SpecialtyPhase = reader.GetString(3);
			if (!reader.IsDBNull(4)) entity.BranchName = reader.GetString(4);
			if (!reader.IsDBNull(5)) entity.BranchShortName = reader.GetString(5);
			if (!reader.IsDBNull(6)) entity.Isdept = reader.GetString(6);
			if (!reader.IsDBNull(7)) entity.Isdel = reader.GetString(7);
			if (!reader.IsDBNull(8)) entity.Canlog = reader.GetString(8);
			if (!reader.IsDBNull(9)) entity.MinBranchId = reader.GetString(9);
			if (!reader.IsDBNull(10)) entity.Rank = reader.GetString(10);
			if (!reader.IsDBNull(11)) entity.Trainall = reader.GetString(11);
			if (!reader.IsDBNull(12)) entity.Bzs = reader.GetInt32(12);
			if (!reader.IsDBNull(13)) entity.Gbbzs = reader.GetInt32(13);
			if (!reader.IsDBNull(14)) entity.Zsbzs = reader.GetInt32(14);
			if (!reader.IsDBNull(15)) entity.Lnndcj = reader.GetString(15);
			if (!reader.IsDBNull(16)) entity.Lndjpd = reader.GetString(16);
			if (!reader.IsDBNull(17)) entity.Lnhdry = reader.GetString(17);
			if (!reader.IsDBNull(18)) entity.Lnjcjs = reader.GetString(18);
			if (!reader.IsDBNull(19)) entity.Lncjdxhd = reader.GetString(19);
		}
		
		

        protected override DbCommand ConstructSelectConditionCommand(Database db, string condition)
        {
            return db.GetSqlStringCommand(SQL_SELECT + condition);
        }
		
		#endregion	
		
		#region Count模块 Helper

        protected override DbCommand ConstructCountCommand(Database db)
        {
            return db.GetSqlStringCommand(SQL_COUNT);
        }

        protected override DbCommand ConstructCountConditionCommand(Database db, string condition)
        {
            return db.GetSqlStringCommand(SQL_COUNT + condition);
        }

		#endregion
		
		#region IsExist模块 Helper

        protected override DbCommand ConstructIsExistCommand(Database db, MoBranchInfo entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_EXIST);
			db.AddInParameter(dbCommand,"BranchId",DbType.AnsiString,entity.BranchId);
			return dbCommand;
        }

		#endregion

		
		
	}
}	
#endregion

